/*
 *    Copyright (c) 2018-2025, lengleng All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the pig4cloud.com developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: lengleng (wangiegie@gmail.com)
 */

package com.pig4cloud.pigx.user.vo;


import lombok.Data;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import java.io.Serializable;

/**
 * api配置VO
 *
 * @since 2022-10-31 15:36:10
 */
@Data
public class UserApiConfigVO implements Serializable {

	private static final long serialVersionUID = 1L;

	/**
	 * 每个用户最多可创建ApiKey的数量
	 */
	@NotNull(message = "参数异常，maxApiKeyNumPerUser为空")
	@Min(value = 1, message = "参数异常，每个用户最多可创建ApiKey的数量最小为1")
	@Max(value = 2000000000, message = "参数异常，每个用户最多可创建ApiKey的数量最大为2000000000")
	private Integer maxApiKeyNumPerUser = 30;

	/**
	 * 频繁请求判定次数（检测到频繁请求n次后封禁）
	 */
	@NotNull(message = "参数异常，criteriaForFrequentRequests为空")
	@Min(value = 1, message = "参数异常，频繁请求判定次数最小为1")
	@Max(value = 2000000000, message = "参数异常，频繁请求判定次数最大为2000000000")
	private Integer criteriaForFrequentRequests = 5;

	/**
	 * 重放攻击判定次数（检测到重放攻击n次后封禁）
	 */
	@NotNull(message = "参数异常，criteriaForReplayAttack为空")
	@Min(value = 1, message = "参数异常，重放攻击判定次数最小为1")
	@Max(value = 2000000000, message = "参数异常，重放攻击判定次数最大为2000000000")
	private Integer criteriaForReplayAttack = 2;

	/**
	 * 网络抖动最大延迟量（毫秒）
	 */
	@NotNull(message = "参数异常，maxNetDelay为空")
	@Min(value = 1, message = "参数异常，网络抖动最大延迟量最小为1")
	@Max(value = 2000000000, message = "参数异常，网络抖动最大延迟量最大为2000000000")
	private Long maxNetDelay = 5000L;

	/**
	 * 网络抖动最大提前量（毫秒）
	 */
	@NotNull(message = "参数异常，maxNetAdvance为空")
	@Min(value = 1, message = "参数异常，网络抖动最大提前量最小为1")
	@Max(value = 2000000000, message = "参数异常，网络抖动最大提前量最大为2000000000")
	private Long maxNetAdvance = 1000L;

	/**
	 * 封禁次数重置周期（n分钟之内没有违规行为时，重置当前封禁次数）
	 */
	@NotNull(message = "参数异常，lockCountResetPeriod为空")
	@Min(value = 1, message = "参数异常，封禁次数重置周期最小为1")
	@Max(value = 2000000000, message = "参数异常，封禁次数重置周期最大为2000000000")
	private Integer lockCountResetPeriod = 4320;
}
